Total Complexity | 0 |
Total Lines | 17 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | export interface OnChangeCallback<Type> { |
||
12 | |||
13 | export default class ValueObserver<Type> implements Observer<Type> { |
||
14 | protected adapter: ObserverAdapter<Type>; |
||
15 | protected current: Type; |
||
16 | |||
17 | constructor(initialValue: Type, adapter: ObserverAdapter<Type>) { |
||
18 | 1 | this.current = initialValue; |
|
19 | 1 | this.adapter = adapter; |
|
20 | } |
||
21 | |||
22 | public get value(): Type { |
||
23 | 2 | return this.current; |
|
24 | } |
||
25 | |||
26 | public set value(newValue: Type) { |
||
27 | 1 | this.current = newValue; |
|
28 | 1 | this.adapter.onChange(newValue); |
|
29 | } |
||
31 |